package com.多线程;

import com.ZmqTools.Zmq_Random.Zmq_Random;

import java.util.Arrays;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class Ex1 implements Callable<Integer> {
  @Override
  public Integer call() throws Exception {
    int[] arr = new int[10];
    for (int i = 0; i < 10; i++) {
      arr[i] = Zmq_Random.getAnum(1, 20);
      //      System.out.println(i);
    }
    Arrays.sort(arr);
    System.out.println(Arrays.toString(arr));
    System.out.println(arr[9]);
    return arr[9];
  }

  public static void main(String[] args) throws Exception {
    Ex1 ex1 = new Ex1();
    FutureTask<Integer> f1 = new FutureTask<>(ex1);
    FutureTask<Integer> f2 = new FutureTask<>(ex1);
    Thread t1 = new Thread(f1);
    Thread t2 = new Thread(f2);
    t1.start();
    t2.start();

    int n1 = f1.get();
    int n2 = f2.get();

    System.out.println(n1 - n2);
  }
}
